
import cassys.dataaccess.EvaluationDAO;
import cassys.datatransferobjects.AssessmentDTO;
import cassys.datatransferobjects.AssessmentItemsDTO;
import cassys.datatransferobjects.EvaluationDTO;
import cassys.datatransferobjects.EvaluationItemDTO;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.hibernate.ReplicationMode;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Priyanka
 */
public class TestHibernateTable {
   
	public static void main(String [] args)
	{
		SessionFactory factory_source=testHibernate.getSessionFactory(0);
		Session session_source=factory_source.openSession();
		Transaction tx1=session_source.beginTransaction();
		System.out.println("Debug 1");
                
                
                AssessmentItemsDTO o1=new AssessmentItemsDTO("AssessmentItem1", "punctuality", 10, null, 0, 13);
                AssessmentItemsDTO o2=new AssessmentItemsDTO("AssessmentItem2", "attentiveness", 10, null, 0, 13);
                AssessmentItemsDTO o3=new AssessmentItemsDTO("AssessmentItem3", "participation", 10, null, 0, 13);
                session_source.save(o1);session_source.save(o2);session_source.save(o3);
                
                ArrayList<AssessmentItemsDTO> list1=new ArrayList<AssessmentItemsDTO>();
                list1.add(o1);list1.add(o2);list1.add(o3);
                
                EvaluationItemDTO e1=new EvaluationItemDTO("1", null, "AssessmentItem1", 4);
                EvaluationItemDTO e2=new EvaluationItemDTO("2", null, "AssessmentItem2", 8);   
                session_source.save(e1);session_source.save(e2);
                        
                        
                List<EvaluationItemDTO> list2=new ArrayList<EvaluationItemDTO>();
                list2.add(e1);list2.add(e2);
                
                EvaluationDTO i=new EvaluationDTO(null,"evaluation1", null, null,list2);

                 Set<EvaluationDTO> oo1=new TreeSet<EvaluationDTO>();
                 oo1.add(i);
                
                AssessmentDTO a1=new AssessmentDTO("Assessment1", null, null, 9, 8, null, null, null);
                a1.setAssessmentItems(list1);
                a1.setEvaluations(oo1);
                
                session_source.save(a1);
                System.out.println("Debug 2");
		tx1.commit();
		

//		SessionFactory factory_target=testHibernate.getSessionFactory(1);
//		Session session_target=factory_target.openSession();
//		
//		Transaction tx2=session_target.beginTransaction();
//		System.out.println("Debug 3");
//		
//		session_target.replicate(object0,ReplicationMode.IGNORE);
//		tx2.commit();
		
		session_source.close();
		
		
		
	} 
}
